package android.FiltrosJava;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

public class MirrorFilter extends AbstractImageBasic{		
	/*
	public BufferedImage applyFilter(BufferedImage src) {
		int dimX = src.getWidth();
		int dimY = src.getHeight();
		int gap = 30;
		
		BufferedImage pback = new BufferedImage( dimX + 2 * gap, 2 * dimY + 3 * gap, BufferedImage.TYPE_INT_ARGB);		
		Graphics2D gback = pback.createGraphics();
		gback.setColor(Color.black);		
		gback.fillRect(0, 0, dimX + 2 * gap, 2 * dimY + 3 * gap);		
		gback.drawImage( src, gap, gap, null );		
    	gback.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
    	
    	LinearTransparency trans = new LinearTransparency();
    	trans.settransparencyInterval(0.5f,0.0f);
    	FlipTransform flip = new FlipTransform();
    	flip.setFlipVertical();
    	
    	BufferedImage dst = flip.applyFilter(src);
    	dst = trans.applyFilter(dst);
    	    	
		gback.drawImage( dst, gap, dimY + 2 * gap, null );   	
    	
		return pback;		
	}*/
	
	public BufferedImage applyFilter(BufferedImage src) {
		int dimX = src.getWidth();
		int dimY = src.getHeight();
		int gx = (int) (0.6f * dimX / 2.0f);
		int gy = (int) (0.2f * dimY / 3.0f);
		
		ScaleTransform f = new ScaleTransform(0.4f,0.4f);
		BufferedImage dst = f.applyFilter(src);
						
		Graphics2D gback = src.createGraphics();
		gback.setColor(Color.black);		

		gback.fillRect(0, 0, dimX, dimY);
		gback.drawImage(dst, gx, gy, null );		
    	gback.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
    	
    	LinearTransparency trans = new LinearTransparency();
    	trans.settransparencyInterval(0.5f,0.0f);
    	FlipTransform flip = new FlipTransform();
    	flip.setFlipVertical();
    	
    	dst = flip.applyFilter(dst);
    	dst = trans.applyFilter(dst);
    	    	
		gback.drawImage( dst, gx, (2 * gy) + dst.getHeight(), null );
		gback.dispose();
		dst = null;
		return src;		
	}
}